.data-table {
  position: relative;
  user-select: none;
  transition: all 0.3s ease;
  overflow: hidden;
  border-radius: 4px;

  // 表头
  .table-header {
    position: relative;
    display: flex;
    align-items: center;
    // 460px × 40px, bz54.png背景
    width: 100%;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    background-color: var(--header-bg-color);
    transition: all 0.3s ease;
    z-index: 2;

    .header-cell {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      // SourceHanSansSC Medium, 16px, #56A5FF, 居中对齐, 行高16px
      font-family: SourceHanSansSC, sans-serif;
      font-style: normal;
      line-height: 16px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      cursor: pointer;
      transition: all 0.3s ease;
      padding: 0 8px;
      min-height: 100%;

      &.left {
        justify-content: flex-start;
        text-align: left;
      }

      &.center {
        justify-content: center;
        text-align: center;
      }

      &.right {
        justify-content: flex-end;
        text-align: right;
      }

      &:hover {
        filter: brightness(1.2);
        background-color: rgba(86, 165, 255, 0.1);
      }

      &:active {
        transform: scale(0.98);
      }
    }
  }

  // 表体
  .table-body {
    position: relative;
    width: 100%;

    .table-row {
      position: relative;
      display: flex;
      align-items: center;
      width: 100%;
      cursor: pointer;
      transition: all 0.3s ease;
      border-bottom: 1px solid var(--border-color);

      &:last-child {
        border-bottom: none;
      }

      .table-cell {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        // SourceHanSansSC Normal, 14px, rgba(255,255,255,0.9), 居中对齐, 行高16px
        font-family: SourceHanSansSC, sans-serif;
        font-style: normal;
        line-height: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        transition: all 0.3s ease;
        padding: 0 8px;
        min-height: 100%;

        &.left {
          justify-content: flex-start;
          text-align: left;
        }

        &.center {
          justify-content: center;
          text-align: center;
        }

        &.right {
          justify-content: flex-end;
          text-align: right;
        }
      }

      &:hover {
        background-color: var(--hover-row-color) !important;
        transform: translateX(2px);

        .table-cell {
          filter: brightness(1.1);
        }
      }

      &.selected {
        background-color: var(--selected-row-color) !important;
        
        .table-cell {
          filter: brightness(1.2);
          text-shadow: 0px 0px 4px rgba(86, 165, 255, 0.5);
        }
      }

      &:active {
        transform: translateX(0);
      }
    }
  }

  // 空状态
  .empty-state {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 120px;
    width: 100%;

    .empty-text {
      font-family: SourceHanSansSC, sans-serif;
      font-size: 14px;
      color: rgba(255, 255, 255, 0.5);
      text-align: center;
    }
  }

  // 加载状态
  &.loading {
    .loading-content {
      position: relative;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      height: 120px;
      width: 100%;

      .loading-spinner {
        width: 24px;
        height: 24px;
        border: 2px solid rgba(255, 255, 255, 0.3);
        border-top-color: #56A5FF;
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin-bottom: 12px;
      }

      span {
        font-family: SourceHanSansSC, sans-serif;
        font-size: 14px;
        color: rgba(255, 255, 255, 0.7);
      }
    }
  }

  // 悬停效果
  &:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }

  &:active {
    transform: translateY(0);
  }

  // 主题样式
  &.dark {
    // 默认深色主题
  }

  &.light {
    .table-header {
      background-color: rgba(200, 200, 200, 0.8) !important;

      .header-cell {
        color: rgba(0, 0, 0, 0.9) !important;

        &:hover {
          background-color: rgba(0, 0, 0, 0.1) !important;
        }
      }
    }

    .table-row {
      .table-cell {
        color: rgba(0, 0, 0, 0.8) !important;
      }

      &:hover {
        background-color: rgba(0, 0, 0, 0.05) !important;
      }

      &.selected {
        background-color: rgba(0, 0, 0, 0.1) !important;
      }
    }

    .empty-text {
      color: rgba(0, 0, 0, 0.5) !important;
    }

    .loading-content {
      .loading-spinner {
        border-color: rgba(0, 0, 0, 0.3);
        border-top-color: #1976D2;
      }

      span {
        color: rgba(0, 0, 0, 0.7) !important;
      }
    }
  }

  // 响应式设计
  @media (max-width: 768px) {
    .table-header {
      .header-cell {
        font-size: 14px !important;
        padding: 0 6px;
      }
    }

    .table-body {
      .table-row {
        .table-cell {
          font-size: 12px !important;
          padding: 0 6px;
        }
      }
    }
  }

  @media (max-width: 480px) {
    .table-header {
      .header-cell {
        font-size: 12px !important;
        padding: 0 4px;
      }
    }

    .table-body {
      .table-row {
        .table-cell {
          font-size: 11px !important;
          padding: 0 4px;
        }
      }
    }
  }

  // 焦点可访问性
  &:focus {
    outline: 2px solid rgba(86, 165, 255, 0.5);
    outline-offset: 2px;
  }

  .header-cell:focus,
  .table-row:focus {
    outline: 2px solid rgba(86, 165, 255, 0.8);
    outline-offset: 2px;
  }

  // 高对比度模式
  @media (prefers-contrast: high) {
    .table-header {
      border: 2px solid rgba(86, 165, 255, 0.8) !important;

      .header-cell {
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8) !important;
        font-weight: bold !important;
      }
    }

    .table-row {
      border-bottom: 1px solid rgba(255, 255, 255, 0.3) !important;

      .table-cell {
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8) !important;
      }
    }
  }

  // 减少动画
  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      transition: none !important;
      transform: none !important;
      animation: none !important;
    }

    &:hover {
      transform: none !important;
    }

    .header-cell:hover,
    .table-row:hover {
      transform: none !important;
    }
  }

  // 数据状态
  &.warning {
    .table-header {
      .header-cell {
        color: #FFC107 !important;
      }
    }
  }

  &.danger {
    .table-header {
      .header-cell {
        color: #F44336 !important;
        animation: dangerPulse 1s ease-in-out infinite;
      }
    }
  }

  &.success {
    .table-header {
      .header-cell {
        color: #4CAF50 !important;
      }
    }
  }

  &.disabled {
    pointer-events: none;
    opacity: 0.5;

    * {
      filter: grayscale(1);
    }
  }

  // 动画关键帧
  @keyframes spin {
    to {
      transform: rotate(360deg);
    }
  }

  @keyframes dangerPulse {
    0%, 100% {
      transform: scale(1);
      filter: brightness(1);
    }
    50% {
      transform: scale(1.02);
      filter: brightness(1.3);
    }
  }

  // 特殊效果
  &.enhanced {
    &::before {
      content: '';
      position: absolute;
      top: -2px;
      left: -2px;
      right: -2px;
      bottom: -2px;
      background: linear-gradient(45deg, transparent, rgba(86, 165, 255, 0.3), transparent);
      border-radius: 6px;
      z-index: -1;
      animation: borderFlow 3s linear infinite;
    }

    .table-header .header-cell {
      animation: headerGlow 2s ease-in-out infinite;
    }
  }

  @keyframes borderFlow {
    0% {
      transform: rotate(0deg);
      opacity: 0.5;
    }
    100% {
      transform: rotate(360deg);
      opacity: 0.5;
    }
  }

  @keyframes headerGlow {
    0%, 100% {
      text-shadow: 0px 0px 4px rgba(86, 165, 255, 0.3);
    }
    50% {
      text-shadow: 0px 0px 12px rgba(86, 165, 255, 0.8), 0px 0px 20px rgba(86, 165, 255, 0.4);
    }
  }

  // 错误状态
  &.error {
    &::after {
      content: '数据加载失败';
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background: rgba(255, 0, 0, 0.9);
      color: white;
      padding: 8px 16px;
      border-radius: 4px;
      font-size: 14px;
      font-weight: 500;
      z-index: 15;
    }
  }

  // 更新状态
  &.updating {
    .table-body {
      animation: updateAnimation 0.8s ease-in-out;
    }

    .table-header {
      animation: headerUpdate 1s ease-in-out;
    }
  }

  @keyframes updateAnimation {
    0%, 100% {
      opacity: 1;
    }
    50% {
      opacity: 0.7;
      filter: brightness(1.2);
    }
  }

  @keyframes headerUpdate {
    0%, 100% {
      opacity: 1;
    }
    50% {
      opacity: 0.8;
      filter: brightness(1.1);
    }
  }

  // 排序状态
  &.sortable {
    .header-cell {
      &::after {
        content: '';
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        width: 0;
        height: 0;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-bottom: 4px solid rgba(255, 255, 255, 0.3);
        transition: all 0.3s ease;
      }

      &:hover::after {
        border-bottom-color: rgba(255, 255, 255, 0.6);
      }

      &.sorting-asc::after {
        border-bottom: 4px solid #56A5FF;
        border-top: none;
      }

      &.sorting-desc::after {
        border-top: 4px solid #56A5FF;
        border-bottom: none;
      }
    }
  }

  // 可选择行
  &.selectable {
    .table-row {
      &::before {
        content: '';
        position: absolute;
        left: -4px;
        top: 50%;
        transform: translateY(-50%);
        width: 0;
        height: 0;
        border-top: 6px solid transparent;
        border-bottom: 6px solid transparent;
        border-left: 6px solid transparent;
        transition: all 0.3s ease;
      }

      &.selected::before {
        border-left-color: #56A5FF;
      }

      &:hover::before {
        border-left-color: rgba(86, 165, 255, 0.5);
      }
    }
  }

  // 斑马条纹
  &.striped {
    .table-row:nth-child(even) {
      background-color: var(--alt-row-bg-color);
    }
  }

  // 紧凑模式
  &.compact {
    .table-header {
      height: 32px !important;

      .header-cell {
        font-size: 14px !important;
        padding: 0 6px;
      }
    }

    .table-body {
      .table-row {
        height: 32px !important;

        .table-cell {
          font-size: 12px !important;
          padding: 0 6px;
        }
      }
    }
  }

  // 边框模式
  &.bordered {
    border: 1px solid var(--border-color);

    .table-header {
      border-bottom: 1px solid var(--border-color);

      .header-cell {
        border-right: 1px solid var(--border-color);

        &:last-child {
          border-right: none;
        }
      }
    }

    .table-body {
      .table-row {
        border-bottom: 1px solid var(--border-color);

        .table-cell {
          border-right: 1px solid var(--border-color);

          &:last-child {
            border-right: none;
          }
        }
      }
    }
  }

  // 固定表头
  &.sticky-header {
    .table-header {
      position: sticky;
      top: 0;
      z-index: 10;
    }
  }

  // 虚拟滚动
  &.virtual-scroll {
    .table-body {
      max-height: 400px;
      overflow-y: auto;

      /* 自定义滚动条 */
      &::-webkit-scrollbar {
        width: 6px;
      }

      &::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 3px;
      }

      &::-webkit-scrollbar-thumb {
        background: rgba(86, 165, 255, 0.5);
        border-radius: 3px;

        &:hover {
          background: rgba(86, 165, 255, 0.7);
        }
      }
    }
  }

  // 实时数据
  &.realtime {
    .table-header::after {
      content: '';
      position: absolute;
      top: 4px;
      right: 4px;
      width: 8px;
      height: 8px;
      background: #4CAF50;
      border-radius: 50%;
      animation: realtimePulse 2s ease-in-out infinite;
      z-index: 10;
    }

    .table-body {
      animation: realtimeUpdate 3s ease-in-out infinite;
    }
  }

  @keyframes realtimePulse {
    0%, 100% {
      opacity: 1;
      transform: scale(1);
    }
    50% {
      opacity: 0.6;
      transform: scale(1.3);
    }
  }

  @keyframes realtimeUpdate {
    0%, 100% {
      filter: brightness(1);
    }
    50% {
      filter: brightness(1.05) saturate(1.1);
    }
  }
} 